Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Sidebar and Event/Venue Panels opening by default #935

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

ajskelton
Copy link
Contributor

Description of the Change

This PR updates the scrips that register the PluginDocumentSettingPanel slotfills for Events and Venues and ensures the General Sidebar, the Events Settings Panel, and the Venue Settings Panel all open by default.

The initialOpen property was added to both event and venue slotfills, however the PluginDocumentSettingPanel slotfill does not accept the property. It uses a useSelect to detect weather the panel is opened and passes that to the <Panel>. The opened property overrides the initialOpen which could be why that property isn't allowed.

The dependency for the PluginDocumentSettingPanel was moved to '@wordpress/editor' and there were deprecation warnings showing in the browser console. I updated the dependency.

In the event-settings and venue-settings panel registration there was a dispatch to toggle the settings panel open. One issue with toggling is when the panel is already open, it would be closed. To fix this I first check if the panel is open before toggling. I wrapped these in a domReady() to make sure the DOM was fully loaded, then use the 'core/edit-post' select to see if the panel is open.

The toggling of the panels was also moved, so I updated the use of the toggleEditorPanelOpened() functions to use the 'core/editor' dispatch. instead of 'core/edit-post'.

In the editor.js file there was a domReady that was making sure the main sidebar was open, but it also was duplicating the work of opening the event sidebar. I removed the duplicate functionality and just use this script to make sure the general sidebar is open.

Closes #891

How to test the Change

  1. Create a new Event
  2. Close the Event Settings Panel
  3. Exit the Event and reopen, or reload the page.
  4. The Event Settings Panel has been opened on page load
  5. Close the General Sidebar
  6. Exit and Event and reopen, or reload the page.
  7. The General Sidebar and the Event Settings Panel are both Open

This also works for the Venue Settings Panel

Changelog Entry

  • Removed the initialOpen property from PluginDocumentSettingPanel
  • Changed the dependency for importing the PluginDocumentSettingPanel
  • Fixed the functions to ensure the Event and Venue settings are opened by default.
  • Removed the duplicate opening of the event settings panel in the editor.js file and only checks and opens the general sidebar.

Credits

Props @ajskelton

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

ajskelton and others added 2 commits October 3, 2024 09:06
* Removes the initialOpen property from PluginDocumentSettingPanel, this slotfill does not allow the property
* Updates the dependency the PluginDocumentSettingPanel is loaded from. It was moved to '@wordpress/editor'
* Updates the function to ensure the Event and Venue settings are opened by default. Uses a domReady and first checks if the panel is open, and if it is not then dispatches a toggleEditorPanelOpened() to open the panel.
* Updates the main domReady in the editor.js file. Removes the duplicate opening of the event settings panel and only checks and opens the general sidebar.
Copy link

github-actions bot commented Oct 4, 2024

Preview changes with Playground

You can preview the recent changes for PR#935 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@mauteri mauteri merged commit 4169145 into GatherPress:main Oct 4, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open the „Event Settings“ panel by default inside the block-Editor is broken, doesn’t open.
2 participants